package com.swt.agy.backend.controller;

import com.swt.agy.backend.model.entity.DictCity;
import com.swt.agy.backend.service.DictCityService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @ClassName DictCityController
 * @Author 杨靖
 * @Date DATE{TIME}
 * @Description TODO
 */
@RestController
@RequestMapping("/dict")
@Api(tags = "测试接口")
public class DictCityController {
    @Autowired
    private DictCityService dictCityService;

    @ApiOperation("01 地区查询")
    @GetMapping(value = "/selectAllDict")
    public ResponseEntity selectAllDict(){
        List<DictCity> list = dictCityService.getAllDictCity();

        //System.out.println(list);
       // return ResponseEntity.status(HttpStatus.OK).body(list);
        return ResponseEntity.ok(list);
    }
    @ApiOperation("02 地区按省份查询")
    @GetMapping(value = "/selectDictByProvince")
    public ResponseEntity selectDictByProvince(Integer provinceId){
        List<DictCity> list = dictCityService.getDictCity(provinceId);

        //System.out.println(list);
        // return ResponseEntity.status(HttpStatus.OK).body(list);
        return ResponseEntity.ok(list);
    }
    @ApiOperation("03 地区按省份Id查询")
    @GetMapping(value = "/selectDictByProvinceId")
    public ResponseEntity selectDictByProvinceId(Integer provinceId){
        List<DictCity> list = dictCityService.findDictCityByProId(provinceId);

        //System.out.println(list);
        // return ResponseEntity.status(HttpStatus.OK).body(list);
        return ResponseEntity.ok(list);
    }
    @ApiOperation(value = "模糊查询地区名称",notes = "模糊查询地区名称")
    @GetMapping("selectByCityName")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "query",dataType = "string",name = "cityName",value = "地区名称")
    })
    @ApiResponse(code = 200,message = "ok",response = Map.class)
    public ResponseEntity selectByCityName(@RequestParam(required = false) String cityName){
            return ResponseEntity.ok(dictCityService.selectByCityName(cityName));
    }
}
